package usercontroller

import (
	"github.com/gin-gonic/gin"
	"services/userservice"
	"controllers"
)

//注册
func Register(c *gin.Context) {
	phoneNumber := c.PostForm("phoneNumber")
	userName := c.PostForm("name")
	email := c.PostForm("email")
	password := c.PostForm("password")
	res := userservice.Register(phoneNumber, userName, email, password)
	controllers.SendResponse(c, res)
}

//发送验证码
func SendRegisterSmsCode(c *gin.Context) {
	phoneNumber := c.PostForm("phone")
	res := userservice.SendRegisterSmsCode(phoneNumber)
	controllers.SendResponse(c, res)
}

//重置密码
func ResetPassword(c *gin.Context) {
	smsCode := c.PostForm("smsCode")
	phoneNumber := c.PostForm("phoneNumber")
	newPassword := c.PostForm("newPassword")
	res := userservice.ResetPassword(smsCode, phoneNumber, newPassword)
	controllers.SendResponse(c, res)
}
